package com.zzlzd.drp.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @author ceshi
 * @Title:
 * @Package
 * @Description:
 * @date 2021-3-246:38
 */
public interface DesignRep extends JpaRepository<DesignDto,Integer> {

    @Query(nativeQuery=true, value=" SELECT * FROM design WHERE site = 0 order by sort")
    public List<DesignDto> index();

    @Query(nativeQuery=true, value=" SELECT d.*,g.goods_img FROM design d LEFT JOIN goods g ON d.gid=g.id WHERE d.site = 0 order by d.sort")
    public List<DesignDto> indexMap();

    @Query(nativeQuery=true, value=" SELECT * FROM design WHERE site = 1 order by sort")
    public List<DesignDto> home();

    @Query(nativeQuery=true, value=" SELECT d.*,a.title FROM design d LEFT JOIN article a on a.id = d.gid WHERE d.site = 1 order by d.sort")
    public List<Map<String,Object>> homeMap();

}
